home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / System 7 / AppleScript / Finder Liaison 1.1.1.sit / Finder Liaison ReadMe < prev   
Encoding:
Text File  |  1994-01-24  |  9.5 KB  |  196 lines  |  [TEXT/ttxt]

  1. Finder Liaison
  2. version 1.1.1  24-Jan-94
  3.  
  4. Description:
  5. Finder Liaison sends AppleEvents to the Finder. Requires System 7 or later.
  6.  
  7. Usage:
  8. The System 7 Finder supports the Finder Suite of AppleEvents. Unfortunately, there is no way to explicitly send AppleEvents to the Finder from AppleScript. Finder Liaison acts as an intermediary between AppleScript and the Finder.
  9.  
  10. Distribution:
  11. Finder Liaison is copyrighted, but free, commonly called Freeware. The author retains all rights to the program, but specifically allows redistribution via the following channels:
  12.  
  13. (1) The disk associated with the book "The Tao of AppleScript" by BMUG
  14. (2) Non-commercial bulletin board services
  15. (3) The following commercial BBS's: America Online, CompuServe, AppleLink
  16. (4) Internet archives and file servers
  17. (5) Disk libraries of non-profit organizations
  18. (6) Free exchange between individuals
  19.  
  20. In all cases, this ReadMe file must accompany the program.
  21.  
  22. For-profit companies that sell software programs must receive explicit written permission from the author before distributing the program.
  23.  
  24. Commercial BBS's not mentioned above must contact the author for permission before uploading the program. I will normally give permission to such BBS's; I just want to know where the program is being uploaded.
  25.  
  26. Credits:
  27. Written by: Gregory H. Dow
  28. Icons by: Chris Holmes
  29. Useful ideas by: Derrick Schneider
  30.  
  31. ©1993-1994 Gregory H. Dow. All rights reserved.
  32.  
  33. Send comments to:
  34. Gregory H. Dow
  35. 1678 Shattuck Ave #302
  36. Berkeley, CA  94709-1631
  37.  
  38. America Online: GHD
  39. Internet: ghd@aol.com
  40.  
  41. • Version History
  42. 1.0         11-Jun-93     Ships with "The Tao of AppleScript" book by BMUG
  43. 1.1b1        23-Aug-93    Supports full path names for files and folders
  44. 1.1b2        05-Oct-93        Updates Finder display when changing the Creator/Type/Name
  45.                                                                             of a File/Folder which is in an open window
  46. 1.1b3        07-Oct-93    Supports creating new folders
  47. 1.1        10-Nov-93    New release
  48. 1.1.1b1 16-Dec-93    Added "wait till done" parameter for certain commands
  49. 1.1.1     24-Jan-94    New release
  50.  
  51.  
  52. • AppleEvents supported by Finder Liaison:
  53.  
  54. Show About This Mac
  55. Empty Trash [with wait till done]
  56. Restart
  57. Show Clipboard
  58. Shut Down
  59. Sleep
  60.  
  61. Close Window of <Folder or Disk>
  62. Print Window of <Folder or Disk>
  63. Page Setup for <Folder or Disk>
  64.         Example: Close Window of Folder "Documents" of Disk "HD80"
  65.  
  66. Open <File or Folder or Disk>
  67. Duplicate <File or Folder or Disk> [with wait till done]
  68. Get Info for <File or Folder or Disk>
  69. Make Alias of <File or Folder or Disk>
  70. Print <File or Folder or Disk>
  71. Put Away <File or Folder or Disk>
  72. Reveal <File or Folder or Disk>
  73. Show Sharing for <File or Folder or Disk>
  74.         Examples:  Open File “Letter” of Folder “Correspondence” of Disk “Personal”
  75.                           Put Away Disk “Floppy”
  76.                           Duplicate File “abc” of Folder “Desktop Folder” of Disk “HD20”
  77.                                  Note: This is how to refer to a File/Folder on the Desktop
  78.  
  79. Set View of <Folder or Disk> to <view option>
  80.     <view option> may be: by Small Icon, by Icon, by Name, by Date, by Size, by Kind, by Comment, by Label, by Version
  81.         Example: Set View of Folder "Icons" of Disk "Art" To by Name
  82.  
  83. Move Window of <Folder or Disk> To <location>
  84.     <location> is the {left,top} position
  85.         Example:  Move Window of Folder "Programs" of Disk "HD40" To {200,50}
  86.  
  87. Set Window Size of <Folder or Disk> to <size>
  88.     <size> is {width,height}
  89.         Example:  Set Window Size of Disk “My Drive” To {500, 300}
  90.  
  91. Zoom Out Window of    <Folder or Disk>
  92. Zoom In Window of    <Folder or Disk>
  93.         Example:    Zoom In Window of Folder “xx” of Folder “yy” of Disk “zz”
  94.  
  95. Move    <File or Folder of Disk>    To    <Folder or Disk>    [At    <location>] [with wait till done]
  96. Drag Copy of    <File or Folder of Disk>    To    <Folder or Disk>    [At    <location>] [with wait till done]
  97.     <location> is an optional parameter specifying the {top,left} position
  98.         Example:    Move File “script” of Disk “HD40” To Folder “xx” of Disk “HD40” At {10, 50}
  99.                        Drag Copy of Folder “tables” of Disk “Drive” To Folder “x” of Disk “Drive” with wait till done
  100. * The optional <location> parameter is supposed to specify where in the window to move/drag the icons. However, it doesn’t appear to work in a consistent or understandable manner.
  101. * See discussion below about "Waiting for command completion" for an explanation of the "wait till done" optional parameter
  102.  
  103. Set Creator of    <File>    To    <ostype>
  104. Set Type of    <File>    To    <ostype>
  105.     <ostype> is a four-character code (it is an error if <ostype> is not exactly four characters)
  106.         Example:    Set Creator of File “letter” of Disk “HD80” To “MSWD”
  107.  
  108. Get Creator of    <File>
  109. Get Type of    <File>
  110.     returns Creator/Type code of the specified file as a four-character string
  111.         Example: Get Creator of File “spreadsheet” of Folder “docs” of Disk “mine”
  112.  
  113. Set Name of    <File or Folder of Disk>    To    <Name>
  114.         Example: Set Name of File “untitled” of Disk “HD40” To “My Letter”
  115.  
  116. Get Path of    <File or Folder of Disk>
  117.     returns the full pathname for the specified item. Does not matter if item exists or not (since you many want to use this pathname to create a new file).
  118.         Example: Get Path of File “script” of Folder “stuff” of Disk “HD160”
  119.  
  120. Create    <File or Folder>    [replacing     <yes/no>]
  121.     creates an empty File (with both data and resource forks). The optional 'replacing' parameter specifies whether to replace the file if it already exists. The default is no.
  122.         Example: Create File “Empty” of Folder “Docs” of Disk “HD20” replacing yes
  123. The 'replacing' parameter is not supported for folders, and it is an error to use
  124. 'replacing' when creating a folder.
  125.         Example: Create Folder "Papers" of Disk "HD80"
  126.  
  127. Get Files in    <Folder of Disk>
  128.     returns a list of the names of the Files in the specified Folder or Disk. Not full pathnames, just the file names.
  129.         Example: Get Files in Folder “Letters” of Disk “HD50”
  130.  
  131. Get Folders in    <Folder of Disk>
  132.     returns a list of the names of the Folders in the specified Folder or Disk . Not full pathnames, just the folder names.
  133.         Example: Get Folders in Folder “Applications” of Disk “HD60”
  134.  
  135.  
  136. • Specifying Files, Folders, or Disks
  137.     
  138. You can specify a File by a container list, such as:
  139.     File "agenda" of Folder "Documents" of Folder "Personal" of Disk "HardDrive"
  140. Or, you can use a full path name, which for the same example as above is:
  141.     File "HardDrive:Personal:Documents:agenda"
  142. A full path name specifies the names in the reverse order, separating folder and disk names with a colon (":").
  143.  
  144. The same holds true for Folders. Here is an example container list:
  145.     Folder "Notes" of "Folder "Meetings" of Disk "Accounting"
  146. And here is the same folder as a full path name:
  147.     Folder "Accounting:Meetings:Notes:"
  148. The colon at the end is *very* important. That's how you distinguish a folder from a file. In a full path name, you can think of a folder or disk name as including the trailing colon.
  149.  
  150. For Disks, there isn't much difference between a container list and a full path. The container list specification doesn't have a colon, the full path name does.
  151.     Container List:   Disk "My Floppy"
  152.     Full Path Name:  Disk "My Floppy:"
  153.  
  154. Normally, you should use the container list form in your scripts, However, the full path name form is needed when accessing files from the list of items returned by the "on open" message. You use this message to create script applications with drag-and-drop capability (called a "droplet"). The string representation of an item from the list returned by "on open" is a full path name. You can distinguish files from folders/disks by checking if the string ends with a colon (file names don't end with a colon; folder and disk names do end with a colon).
  155.  
  156. Here is an example script for a droplet that operates on the items dropped on it by creating aliases of folders and disks and duplicating files:
  157.  
  158. on open (theItems)
  159.     tell application "Finder Liaison 1.1.1b1"
  160.         repeat with currItem in theItems
  161.             copy (currItem as string) to pathName
  162.             if pathName ends with ":" then
  163.                 -- item is a folder or disk, create an Alias
  164.                 Make Alias of Folder pathName
  165.             else
  166.                 -- item is a file, Duplicate it
  167.                 Duplicate File pathName
  168.             end if
  169.         end repeat
  170.     end tell
  171. end open
  172.  
  173. Note that it's OK to refer to all path names ending with a colon as Folders, even though they may actually be disks. Finder Liaison treats Folders and Disks the same; they both are containers of (other) folders and files.
  174.  
  175.  
  176. • Waiting for command completion
  177.  
  178. The following commands all have an optional "wait till done" parameter:
  179.     Empty Trash
  180.     Duplicate
  181.     Move
  182.     Drag Copy Of
  183.  
  184. The Finder performs these operations in the background. If you don't specify "wait till done", your script may resume execution before the command has completed. This can cause problems if you want to perform a subsequent operation on the same items.
  185.  
  186. The default value of "wait till done" is false. 
  187.  
  188. Here is an example script which copies a folder to another disk, moves the original folder to the trash, and then empties the trash:
  189.  
  190. tell application "Finder Liaison 1.1.1b1"
  191.    Drag Copy Of Folder "Letters" of Disk "Work" to Disk "Backup" with wait till done
  192.    Move Folder "Letters" of Disk "Work" to Folder "Trash" of Disk "Work" with wait till done
  193.    Empty Trash
  194. end tell
  195.  
  196. The Drag Copy Of, Move, and Empty Trash command all operate on the same Folder. If you don't "wait till done" before executing the next command, the Folder could get moved to the trash before the copying is finished, which means that some files could get thrown out before they got copied [a bad thing].